package me.xuym.crawler.house58;

import me.xuym.crawler.simpleextension.dispatcher.SimpleDebugDispatcherInput;
import me.xuym.crawler.simpleextension.filter.SimpleCachedFilterInput;
import net.duguying.pinyin.Pinyin;

import java.util.Hashtable;
import java.util.Map;

/**
 * Created by broche on 10/09/2017.
 */
public class House58DeltaAddress implements SimpleCachedFilterInput, SimpleDebugDispatcherInput {
    private String address;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public Map<String, String> simpleCachedFilterCheckFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("address", getAddress());
        return fields;
    }

    @Override
    public Map<String, String> simpleCachedFilterSaveFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("address", getAddress());
        fields.put("addressfinal", getAddress());
        fields.put("py", "");
        try {
            fields.put("py", new Pinyin().translateFirstChar(getAddress()));
        } catch (Exception e) {
        }
        return fields;
    }

    @Override
    public String simpleDebugDispatcherContent() {
        return getAddress();
    }
}
